﻿using RefactorThis.GraphDiff.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TanmiaGrp.Basis.Core;

namespace TanmiaGrp.GeneralLedger.Core
{
    public class Voucher : BusinessObject
    {
        private int voucherID;
        private string source;
        private string sourceID;
        private string notes;
        private double totalCredit;
        private double totalDebit;
        private double balance;
        private BusinessObjectCollection<VoucherDetail> voucherDetail;

        [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
        public int VoucherID
        {
            get { return voucherID; }
            set
            {
                if (voucherID != value)
                {
                    voucherID = value;
                    RaisePropertyChanged(() => VoucherID);
                }
            }
        }

        [MaxLength(64)]
        public string Source
        {
            get { return source; }
            set
            {
                if (source != value)
                {
                    source = value;
                    RaisePropertyChanged(() => Source);
                }
            }
        }

        [MaxLength(64)]
        public string SourceID
        {
            get { return sourceID; }
            set
            {
                if (sourceID != value)
                {
                    sourceID = value;
                    RaisePropertyChanged(() => SourceID);
                }
            }
        }

        [MaxLength(255)]
        public string Notes
        {
            get { return notes; }
            set
            {
                if (notes != value)
                {
                    notes = value;
                    RaisePropertyChanged(() => Notes);
                }
            }
        }

        [Range(0, double.MaxValue)]
        public double TotalCredit
        {
            get { return totalCredit; }
            set
            {
                if (totalCredit != value)
                {
                    totalCredit = value;
                    RaisePropertyChanged(() => TotalCredit);
                }
            }
        }

        [Range(0, double.MaxValue)]
        public double TotalDebit
        {
            get { return totalDebit; }
            set
            {
                if (totalDebit != value)
                {
                    totalDebit = value;
                    RaisePropertyChanged(() => TotalDebit);
                }
            }
        }

        public double Balance
        {
            get { return balance; }
            set
            {
                if (balance != value)
                {
                    balance = value;
                    RaisePropertyChanged(() => Balance);
                }
            }
        }

        [Owned]
        public BusinessObjectCollection<VoucherDetail> VoucherDetail
        {
            get { return voucherDetail; }
            set
            {
                if (voucherDetail != value)
                {
                    voucherDetail = value;
                    RaisePropertyChanged(() => VoucherDetail);
                }
            }
        }
    }
}
